<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
    <head>
        <title>Connexion Intranet</title>
        <link type="text/css" rel="stylesheet" href="form.css" />
        <style type="text/css">
		  body {
			padding-top: 160px;
			padding-bottom: 40px;
		  }
	</style>
    </head>


    <body>
        <%@page import="Session.RedacteurSessionLocal"%>
        <!--Ne pas oublier les import des autres-->
        <%--<%@page import="Session.RedacteurSessionLocal"%>--%>
        <%--<%@page import="Session.RedacteurSessionLocal"%>--%>
        <%@page import="javax.naming.InitialContext" %>
        <%@page import="javax.ejb.EJBException" %>
        <%
            String pseudo = request.getParameter("login");
            String pwd = request.getParameter("password");

            if (pseudo == null || pseudo.equals("") || pwd == null || pwd.equals("")) {
                if (request.getMethod().equals("POST")) { // Form is partially filled-in
        %>
        <p>Champs vides</p>
        <%
            }
        } else {//if (user.equals("redacteur")) {
            try {
                InitialContext ic = new InitialContext();
                RedacteurSessionLocal rsl = (RedacteurSessionLocal) ic.lookup("java:comp/env/RedacteurSessionLocal");
                if (rsl.connexion(pseudo, pwd)) {
                    session.setAttribute("login", pseudo);

                    response.sendRedirect("ActionRedacteur.jsp");
                }
            } catch (EJBException e) {
        %>
        <p> error <%=e.getLocalizedMessage()%>, ERREUR DANS L EXCEPTION</p>
        <%
                }
            }
        %>

      <div class="navbar navbar-inverse navbar-fixed-top">
         <div class="navbar-inner">
            <div class="container">
                <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="brand" id="logo" href="#">Assur'Tout</a>
            </div>
         </div>
      </div>

     <div class="container">
           <div class="hero-unit" align=center>
                <form  method="post" action="">
                    <h1>Identification</h1>   <br>      
                        <table>
                            <tr>
                                <td>Login</td>
                                <td><input type="text" name="login" size="25" value=""></td>
                            </tr>
                            <tr>
                                <td>Password</td>
                                <td><input type="password" name="password" size="25" value=""></td>
                            </tr>
                             <tr>                
                                <td>Utilisateur</td>
                                 <td>Redacteur<input type="radio" name="user" value="redacteur" checked /></td>

                        <!--<td>Actuaire<input type="radio" name="user" value="actuaire" /></td>-->
                        <td>Centre d'appel<input type="radio" name="user" value="centreAppel" /></td>
                            </tr>

                        </table>
                    <input type="submit" class="btn btn-primary btn-large" name="submit" value="Connexion">
           
                    </form>
                </div>
             </div>
	 <footer> 
             <div align=center> Guillaume DI LIBERATORE - Mylène DOITEAU - Adrien HENRIET - Nathan KRUCK - Kilian POMIER - Gautier ROLS</div>
         </footer>
    </body>
</html>


